import 'package:flutter/material.dart';

class PhysicalHomePage extends StatefulWidget {
  @override
  _PhysicalHomePageState createState() => _PhysicalHomePageState();
}

class _PhysicalHomePageState extends State<PhysicalHomePage> {
  Color _shadowColor = Colors.grey;
  num index = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("physicalModel 自定义阴影"),
      ),
      backgroundColor: Colors.white,
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: () {
          index++;
          int flag = index % 3;
          if (flag == 0) {
            _shadowColor = Colors.blue;
          } else if (flag == 1) {
            _shadowColor = Colors.red;
          } else {
            _shadowColor = Colors.yellow;
          }
          setState(() {});
        },
      ),
      body: Column(
        children: [
          Center(
            child: PhysicalModel(
              // 阴影形状
              shape: BoxShape.rectangle,
              // 阴影的圆角
              // borderRadius: BorderRadius.all(Radius.circular(20)),
              // 阴影高度，默认为零
              elevation: 10.0,
              // 背景颜色，默认为#ff0000
              color: Colors.deepPurple,
              shadowColor: Colors.green,
              child: Container(
                width: 200,
                height: 200,
                color: Colors.white,
              ),
            ),
          ),
          SizedBox(height: 100),
          Center(
            child: AnimatedPhysicalModel(
              // 阴影形状
              shape: BoxShape.rectangle,
              // 阴影的圆角
              // borderRadius: BorderRadius.all(Radius.circular(20)),
              // 阴影高度，默认为零
              elevation: 20.0,
              duration: Duration(milliseconds: 600),
              // 背景颜色，默认为#ff0000
              color: Colors.deepPurple,
              shadowColor: _shadowColor,
              child: Container(
                width: 200,
                height: 200,
                color: Colors.white,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
